<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>main</title>
    <style>
        html, body {
            height: 100%;
            overflow: hidden;
            touch-action: none;

        }

        * {
            padding: 0;
            margin: 0;
        }

        .callback {
            border: 1px solid red;
            height: 50px;
        }
    </style>
</head>
<body>
<div id="console">
    <div class="callback"></div>
    <iframe src="http://localhost:8080/static/cloud-i.html" frameborder="0" width="900px" height="400px"></iframe>
</div>

<script type="text/javascript">
    window.addEventListener("message", receiveMessage, false);

    function receiveMessage(event) {
        var origin = event.origin;
        console.log(event);
    }

    var storage = window.localStorage;
    storage.removeItem('data')  //storage 和  change 事件触发条件相似 初始化时需要清空或设置为 ""
    window.addEventListener('storage', storageChange, false)

    function storageChange(e) {
        document.getElementsByClassName('callback').innerHTML = storage.getItem('data')
    }
</script>
</body>
</html>
